<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" th:replace="~{layout/base :: layout(~{::title}, ~{::content}, ~{::css}, ~{::js})}">
<head>
    <title>首页 - 笔记管理系统</title>
    <th:block th:fragment="css">
        <style>
            .hero-section {
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                color: white;
                padding: 60px 0;
                margin: -30px -30px 30px -30px;
                border-radius: 10px 10px 0 0;
            }
            .stats-card {
                background: rgba(255,255,255,0.1);
                backdrop-filter: blur(10px);
                border: 1px solid rgba(255,255,255,0.2);
                border-radius: 15px;
                padding: 20px;
                text-align: center;
                color: white;
            }
            .stats-number {
                font-size: 2.5rem;
                font-weight: bold;
                margin-bottom: 10px;
            }
            .note-preview {
                border-left: 4px solid #007bff;
                padding: 15px;
                margin-bottom: 15px;
                background: white;
                border-radius: 8px;
                box-shadow: 0 2px 8px rgba(0,0,0,0.1);
                transition: all 0.3s;
            }
            .note-preview:hover {
                transform: translateX(5px);
                box-shadow: 0 4px 15px rgba(0,0,0,0.15);
            }
            .note-title {
                font-size: 1.1rem;
                font-weight: 600;
                color: #333;
                margin-bottom: 8px;
            }
            .note-summary {
                color: #666;
                font-size: 0.9rem;
                line-height: 1.5;
                margin-bottom: 10px;
            }
            .note-meta {
                font-size: 0.8rem;
                color: #999;
                display: flex;
                justify-content: space-between;
                align-items: center;
            }
            .quick-actions {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
                gap: 20px;
                margin-bottom: 30px;
            }
            .action-card {
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                color: white;
                padding: 25px;
                border-radius: 15px;
                text-align: center;
                text-decoration: none;
                transition: all 0.3s;
                border: none;
            }
            .action-card:hover {
                transform: translateY(-5px);
                box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
                color: white;
                text-decoration: none;
            }
            .action-icon {
                font-size: 2.5rem;
                margin-bottom: 15px;
            }
        </style>
    </th:block>
</head>
<body>
    <div th:fragment="content">
        <!-- 英雄区域 -->
        <div class="hero-section">
            <div class="container">
                <div class="row align-items-center">
                    <div class="col-md-8">
                        <h1 class="display-4 mb-3">欢迎使用笔记管理系统</h1>
                        <p class="lead mb-4">记录生活点滴，整理知识碎片，让思维更有条理</p>
                        <a href="/note/add" class="btn btn-light btn-lg">
                            <i class="fas fa-plus me-2"></i>开始写作
                        </a>
                    </div>
                    <div class="col-md-4">
                        <div class="row">
                            <div class="col-6 mb-3">
                                <div class="stats-card">
                                    <div class="stats-number" th:text="${#lists.size(recentNotes) ?: 0}">0</div>
                                    <div>最近笔记</div>
                                </div>
                            </div>
                            <div class="col-6 mb-3">
                                <div class="stats-card">
                                    <div class="stats-number" th:text="${#lists.size(categories) ?: 0}">0</div>
                                    <div>分类数量</div>
                                </div>
                            </div>
                            <div class="col-6">
                                <div class="stats-card">
                                    <div class="stats-number" th:text="${#lists.size(hotTags) ?: 0}">0</div>
                                    <div>标签数量</div>
                                </div>
                            </div>
                            <div class="col-6">
                                <div class="stats-card">
                                    <div class="stats-number" th:text="${#lists.size(hotNotes) ?: 0}">0</div>
                                    <div>热门笔记</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 快速操作 -->
        <div class="quick-actions">
            <a href="/note/add" class="action-card">
                <div class="action-icon">
                    <i class="fas fa-plus"></i>
                </div>
                <h5>新建笔记</h5>
                <p class="mb-0">记录新的想法和灵感</p>
            </a>
            <a href="/note" class="action-card">
                <div class="action-icon">
                    <i class="fas fa-list"></i>
                </div>
                <h5>浏览笔记</h5>
                <p class="mb-0">查看所有已保存的笔记</p>
            </a>
            <a href="/note/category" class="action-card">
                <div class="action-icon">
                    <i class="fas fa-folder"></i>
                </div>
                <h5>管理分类</h5>
                <p class="mb-0">整理和管理笔记分类</p>
            </a>
            <a href="/note/tag" class="action-card">
                <div class="action-icon">
                    <i class="fas fa-tags"></i>
                </div>
                <h5>管理标签</h5>
                <p class="mb-0">创建和管理笔记标签</p>
            </a>
        </div>

        <div class="row">
            <!-- 最近笔记 -->
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header bg-primary text-white">
                        <h5 class="mb-0">
                            <i class="fas fa-clock me-2"></i>最近笔记
                        </h5>
                    </div>
                    <div class="card-body">
                        <div th:if="${#lists.isEmpty(recentNotes)}" class="text-center text-muted py-4">
                            <i class="fas fa-sticky-note fa-3x mb-3"></i>
                            <p>还没有笔记，<a href="/note/add">立即创建</a>第一篇笔记吧！</p>
                        </div>
                        <div th:each="note : ${recentNotes}" class="note-preview">
                            <div class="note-title">
                                <a th:href="@{'/note/detail/' + ${note.id}}" th:text="${note.title}" class="text-decoration-none">笔记标题</a>
                            </div>
                            <div class="note-summary" th:text="${note.summary}">笔记摘要...</div>
                            <div class="note-meta">
                                <span>
                                    <span class="category-badge" th:text="${note.categoryName}">分类</span>
                                    <span th:if="${note.tagNames}" class="ms-2">
                                        <i class="fas fa-tags me-1"></i>
                                        <span th:text="${note.tagNames}">标签</span>
                                    </span>
                                </span>
                                <span>
                                    <i class="fas fa-eye me-1"></i><span th:text="${note.viewCount}">0</span>
                                    <i class="fas fa-heart ms-2 me-1"></i><span th:text="${note.likeCount}">0</span>
                                </span>
                            </div>
                        </div>
                        <div class="text-center mt-3" th:if="${!#lists.isEmpty(recentNotes)}">
                            <a href="/note" class="btn btn-outline-primary">查看更多</a>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 热门笔记 -->
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header bg-success text-white">
                        <h5 class="mb-0">
                            <i class="fas fa-fire me-2"></i>热门笔记
                        </h5>
                    </div>
                    <div class="card-body">
                        <div th:if="${#lists.isEmpty(hotNotes)}" class="text-center text-muted py-4">
                            <i class="fas fa-fire fa-3x mb-3"></i>
                            <p>暂无热门笔记</p>
                        </div>
                        <div th:each="note : ${hotNotes}" class="note-preview">
                            <div class="note-title">
                                <a th:href="@{'/note/detail/' + ${note.id}}" th:text="${note.title}" class="text-decoration-none">笔记标题</a>
                            </div>
                            <div class="note-summary" th:text="${note.summary}">笔记摘要...</div>
                            <div class="note-meta">
                                <span>
                                    <span class="category-badge" th:text="${note.categoryName}">分类</span>
                                    <span th:if="${note.tagNames}" class="ms-2">
                                        <i class="fas fa-tags me-1"></i>
                                        <span th:text="${note.tagNames}">标签</span>
                                    </span>
                                </span>
                                <span>
                                    <i class="fas fa-eye me-1"></i><span th:text="${note.viewCount}">0</span>
                                    <i class="fas fa-heart ms-2 me-1"></i><span th:text="${note.likeCount}">0</span>
                                </span>
                            </div>
                        </div>
                        <div class="text-center mt-3" th:if="${!#lists.isEmpty(hotNotes)}">
                            <a href="/note" class="btn btn-outline-success">查看更多</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <th:block th:fragment="js">
        <script>
            $(document).ready(function() {
                // 页面加载动画
                $('.card').hide().fadeIn(800);
                $('.note-preview').hide().each(function(index) {
                    $(this).delay(index * 100).fadeIn(400);
                });
            });
        </script>
    </th:block>
</body>
</html>